<%--
  - Author		:	이 영호(Youngho Lee)	
  --%>
<%@ page language="java" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<%@ include file="/WEB-INF/pages/includes/taglibs.jspf" %>
<%@ include file="/WEB-INF/pages/includes/variables.jspf" %>
<%@ include file="/WEB-INF/pages/includes/doctype.jspf" %>
<html>
	<head>
<%@ include file="/WEB-INF/pages/includes/metatags.jspf" %>
		<title><fmt:message key="pages.title" /></title>
		<link rel="stylesheet" type="text/css" href="<c:url value="${dirStyles}/common.css" />" />

		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-1.7.2.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/jquery-ui-1.8.21.custom.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="${dirScripts}/utils.js" />"></script>
		<script type="text/javascript">
			$(function(){
				$(".popupWrap").draggable({ cursor: "pointer", handle: ".pTitle" });
			});
			
			function validation(){
				try{
					with(document.frm){
						var stringUtils = new StringUtils();
						
						if((title.value).replace(/\s/g, '') == ""){
							alert("[제목]은 필수 입력 항목입니다.");
							title.focus();
							return false;
						}
						if((cont.value).replace(/\s/g, '') == ""){
							alert("[내용]은 필수 입력 항목입니다.");
							cont.focus();
							return false;
						}
						if(stringUtils.computeSize(cont.value) > 500){
							alert("[내용]은 500byte까지 입력할 수 있습니다.\\n(현재 입력 byte : "+stringUtils.computeSize(cont.value)+")");
							cont.focus();
							return false;
						}
					}
				}catch(err){
					alert(err);
					return false;	
				}
				
				if(! confirm("테스트결과를 등록 하시겠습니까?")){
					return false;
				}
				
				return true;
			}
			
			function goAction(idx){
				document.detailFrm.idx.value=idx;
				document.detailFrm.submit();
			}

			function goPage(page){
				document.searchFrm.page.value = page;
				document.searchFrm.submit();
			}
		</script>
	</head>
	<body>
<%@ include file="/WEB-INF/pages/includes/header.jsp" %>
		<div class="bodyWrap">
<%@ include file="/WEB-INF/pages/includes/left.jsp" %>
			<div class="contWrap">
				<div class="contMenuTitle">
					<img src="<c:url value="${dirImages}/subtit_05_2.gif" />" title="테스트결과등록" alt="테스트결과등록">
				</div>
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="테스트결과등록" alt="테스트결과등록" > 테스트결과등록
				</div>
				<form name="frm" method="post" enctype="multipart/form-data" action="<c:url value="/tester/submit.do" />" onsubmit="return validation();">
					<input type="hidden" name="maxnum" value="${maxnum}" />
					<input type="hidden" name="page" value="${page}" />
					<input type="hidden" name="searchType" value="${param.searchType}" />
					<input type="hidden" name="searchWord" value="${param.searchWord}" />
					<table class="formTbl">
						<colgroup>
							<col width="100px" />
							<col width="367px" />
							<col width="100px" />
							<col width="*" />
						</colgroup>
						<tbody>
							<tr>
								<th>작성자</th>
								<th>
									${sessionScope.userNm}
								</th>
								<th>작성일</th>
								<th>
									<jsp:useBean id="now" class="java.util.Date" />
									<fmt:formatDate value="${now}" pattern="yyyy/MM/dd" /> 
								</th>
							</tr>
							<tr>
								<th>제목</th>
								<td colspan="3">
									<input type="text" name="title" title="제목" alt="제목" maxlength="25" style="width: 615px;" value="${board.title}" />
								</td>
							</tr>
							<tr>
								<th>내용</th>
								<td colspan="3">
									<textarea name="cont" style="width: 615px; height: 320px;margin: 5px 0;">${board.cont}</textarea>
								</td>
							</tr>
							<tr>
								<th>첨부파일</th>
								<td colspan="3">
									<input type="file" name="boardFile">
									<c:if test="${not empty board.file}">
										<br />
										<a href="${board.file}" target="blank">첨부파일 다운</a>
									</c:if>
								</td>
							</tr>
						</tbody>
					</table>
					<div class="btnWrap rightBtnWrap">
						<c:choose>
							<c:when test="${param.fAct eq 'modify'}">
								<input type="hidden" name="idx" value="${board.idx}">
								<input type="hidden" name="fAct" value="modify">
								<input type="submit" class="btn btn_revision" alt="수정" title="수정" value="">
							</c:when>
							<c:otherwise>
								<input type="submit" class="btn btn_register" alt="등록" title="등록" value="">
							</c:otherwise>
						</c:choose>
						<input type="button" class="btn btn_cancel" alt="취소" title="취소" onclick="javascript:document.listFrm.submit();">
					</div>
				</form>
				<br /><br />
				<div class="secTitle">
					<img src="<c:url value="${dirImages}/icon.png" />" title="테스트결과" alt="테스트결과" > 테스트결과
					<div style="float: right;">
						<form name="searchFrm" method="post" action="<c:url value="/tester/form.do" />">
							<input type="hidden" name="maxnum" value="${param.maxnum}" />
							<input type="hidden" name="page" value="${param.page}" />
							<select name="searchType">
								<option value="title" <c:if test="${param.searchType eq 'title'}"> selected="selected" </c:if>>제목</option>
								<option value="cont" <c:if test="${param.searchType eq 'cont'}"> selected="selected" </c:if>>내용</option>
							</select>
							<input type="text" name="searchWord" value="${param.searchWord}" />
							<input type="submit" class="btn btn_search" alt="검색" title="검색" value="">
						</form>
					</div>
				</div>
				<table class="listTbl">
					<thead>
						<tr>
							<th>번호</th>
							<th>제목</th>
							<th>날짜</th>
							<th class="lastTh">조회</th>
						</tr>
					</thead>
					<c:forEach items="${boardList}" var="board" varStatus="stat">
						<tbody>
							<tr>
								<td>${boardListTotalCnt - stat.index - (maxnum*(page-1))}</td>
								<td><a href="javascript:goAction(${board.idx});"><c:out value="${board.title}" /></a></td>
								<td>
									<a href="javascript:goAction(${board.idx});">
										<c:catch var="e">
											<fmt:parseDate var="date" pattern="yyyy-MM-dd HH:mm:ss" value="${board.createdTime}" />
											<fmt:formatDate value="${date}" pattern="yyyy.MM.dd" />
										</c:catch>
										<c:if test="${not empty e}">
											${board.createdTime}
										</c:if>
									</a>
								</td>
								<td><c:out value="${board.viewCnt}" /></td>
							</tr>
						</tbody>
					</c:forEach>
					<c:if test="${boardListTotalCnt eq 0}">
						<tfoot>
							<tr>
								<td colspan="4">테스트결과가 없습니다.</td>
							</tr>
						</tfoot>
					</c:if>
				</table>
				<c:if test="${boardListTotalCnt ne 0}">
					<div class="pagingWrap">
						<jsp:include page="/WEB-INF/pages/includes/paging.jsp">
							<jsp:param name="totalNum" value="${boardListTotalCnt}" />
							<jsp:param name="pageListCnt" value="${maxnum}" />
							<jsp:param name="pageGrpCnt" value="10" />
							<jsp:param name="pageIdx" value="${page}" />
						</jsp:include>
					</div>
				</c:if>
			</div>
		</div>
		<form name="listFrm" method="post" action="<c:url value="/tester/form.do" />">
			<input type="hidden" name="maxnum" value="${maxnum}" />
			<input type="hidden" name="page" value="${page}" />
			<input type="hidden" name="searchType" value="${param.searchType}" />
			<input type="hidden" name="searchWord" value="${param.searchWord}" />
		</form>
		<form name="detailFrm" method="post" action="<c:url value="/tester/detail.do" />" style="display: none;">
			<input type="hidden" name="idx" value="" />
			<input type="hidden" name="maxnum" value="${maxnum}" />
			<input type="hidden" name="page" value="${page}" />
			<input type="hidden" name="searchType" value="${param.searchType}" />
			<input type="hidden" name="searchWord" value="${param.searchWord}" />
		</form>
<%@ include file="/WEB-INF/pages/includes/footer.jsp" %>
	</body>
</html> 